import { defineStore } from 'pinia';
import { reactive } from 'vue';
// 定义创建文章数据存储对象的方法
const useArticleStore = defineStore('article', () => {
    // 文章列表
    let articleList =reactive([])
    // 初始化文章列表(action)方法
    const getArticleList = async () => {
        const res = await fetch('https://cnodejs.org/api/v1/topics').then(response => response.json());
        // article.articleList=reactive(res.data);
        Object.assign(articleList, res.data);
    }

    const articleDel=(index)=>{
        articleList.splice(index,1);
    }
    return {
        articleList,
        getArticleList,
        articleDel
    }
});
export default useArticleStore;